home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / ANC_UTULITYS_16.adf / arclist / asm2.arc / ten1.S next >
Text File  |  1988-09-21  |  9KB  |  386 lines

  1.  
  2. beg:                    ; As usual...
  3. movem.l    d0/d1/d2/d3/d4/d5/d6/d7/a0/a1/a2/a3/a4/a5/a6,-(a7)
  4. move.l    a7,InitialSP            ; Just to be on the safe side
  5. bsr    SwitchOSout            ; Switch out Operating System
  6. bsr    Initchips            ; Setup Custom chip pointers
  7. bsr    Initint                ; Setup Interrupts.
  8. bsr    InitOther            ; Init the other stuff
  9. bsr    Wait                ; Handle input stuff
  10. bsr    Resetint            ; Reset interrupts
  11. bsr    Resetchips            ; Reset custom chips
  12. bsr    SwitchOSin            ; Switch in Operating System.
  13. move.l    InitialSP,a7            ; Restore Stack Frame Pointer
  14. movem.l    (a7)+,a0/a1/a2/a3/a4/a5/a6/d0/d1/d2/d3/d4/d5/d6/d7
  15. rts
  16.  
  17. InitialSP:dc.l 0            ; Hold initial SP
  18.  
  19. SwitchOSout:                ; Switch out disturbing stuff.
  20. move.l    $4,a6                ; System Base
  21. lea    gfxlib,a1
  22. clr.l    d0
  23. jsr    -552(a6)            ; _LVOOpenLibrary
  24. move.l    d0,gfxbase            ; Save Graphics_lib base
  25. jsr    -$84(a6)            ; _LVOForbid
  26. jsr    -$96(a6)            ; _LVOSuperState
  27. move.l    d0,systack            ; System stack
  28. rts
  29.  
  30. systack:dc.l 0
  31. gfxlib:dc "graphics.library",0,0
  32. gfxbase:dc.l 0
  33.  
  34. Initchips:                ; Initialize custom chips
  35. move.w    $dff01c,intesave
  36. move.w    $dff01e,intrsave
  37. move.w    $dff002,dmasave
  38. move.w    $dff010,adksave
  39. move.w    #%0111111111111111,$dff096    ; DMACONW
  40. move.w    #%1000001111100000,$dff096    ; Disable disk access.
  41. move.w    #%0111111111111111,$dff09a    ; INTENA
  42. move.w    #%1100000000110100,$dff09a    ; Enable desired IRQ's
  43. move.l    #copl,$dff080
  44. rts
  45.  
  46. intesave:dc.w    0
  47. intrsave:dc.w    0
  48. dmasave:dc.w    0
  49. adksave:dc.w    0
  50.  
  51. InitInt:                ; Initialize interrupts
  52. move.l    $6c,level3save            ; Save level 3 vector
  53. move.l    $6c,af3+2
  54. move.l    $68,level2save            ; Save level 2 vector
  55. move.l    $68,af2+2
  56. move.l    #level2irq,$68            ; Set new interrupt vector 2
  57. move.l    #level3irq,$6c            ; Set new interrupt vector 3
  58. rts
  59.  
  60. level2save:dc.l 0
  61. level3save:dc.l 0
  62.  
  63. ResetInt:                ; Reset Interrupts
  64. move.l    level3save,$6c            ; Restore level 3 vector
  65. move.l    level2save,$68            ; Restore level 2 vector
  66. rts
  67.  
  68. Resetchips:                ; Reset custom chips
  69. move.w    intesave,d7
  70. bset    #$f,d7
  71. move.w    d7,$dff09a            ; Reset Interrupts
  72. move.w    intrsave,d7
  73. bset    #$f,d7
  74. move.w    d7,$dff09c            ; Reset interrupt request
  75. move.w    dmasave,d7
  76. bset    #$f,d7
  77. move.w    d7,$dff096            ; Reset DMAConw
  78. move.w    adksave,d7
  79. bset    #$f,d7
  80. move.w    d7,$dff09e            ; Reset ADK
  81. move.l    gfxbase,a0
  82. move.l    $26(a0),$dff080
  83. rts
  84.  
  85. SwitchOSIn:                ; Allow OS to operate again.
  86. move.l    4,a6                ; System Base
  87. jsr    -$8a(a6)            ; _LVOPermit
  88. move.l    systack,d0            ; Systemstack
  89. jsr    -$9c(a6)            ; _LVOUserState
  90. rts
  91.  
  92. level2irq:
  93. af2:jmp 0
  94.  
  95. level3irq:
  96. movem.l    d0/d1/d2/d3/d4/d5/d6/d7/a0/a1/a2/a3/a4/a5/a6,-(a7)
  97. ;move.w    #$000f,$dff180
  98. movem.l    (a7)+,d0/d1/d2/d3/d4/d5/d6/d7/a0/a1/a2/a3/a4/a5/a6
  99. af3:jmp 0
  100.  
  101. rotdly:dc.w 250
  102. rotdirection:dc.w 0
  103. rotate:dc.w 0
  104.  
  105. dorotation:
  106. tst.w    rotate
  107. bne.s    rotatin
  108.  
  109. subq.w    #1,rotdly
  110. bne.s    norot
  111.  
  112. move.w    #150,rotate
  113.  
  114. rotatin:
  115. subq.w    #1,rotate
  116. beq.s    norot3
  117.  
  118. tst.w    rotdirection
  119. bne.s    other
  120.  
  121. lea    dire,a0
  122. moveq    #99,d6
  123. slp:
  124. move.w    (a0),d0
  125. addq.w    #2,d0
  126. cmpi.w    #720,d0
  127. blt.s    nomore
  128. subi.w    #720,d0
  129. nomore:
  130. move.w    d0,(a0)+
  131. dbf    d6,slp
  132. bra.s    norot2
  133.  
  134. other:
  135. lea    dire,a0
  136. moveq    #99,d6
  137. slp2:
  138. move.w    (a0),d0
  139. subq.w    #2,d0
  140. cmpi.w    #0,d0
  141. bge.s    nomore2
  142. addi.w    #720,d0
  143. nomore2:
  144. move.w    d0,(a0)+
  145. dbf    d6,slp2
  146. bra.s    norot2
  147.  
  148. norot3:
  149. eor.w    #$ffff,rotdirection
  150. move.w    #250,rotdly
  151. norot2:
  152.  
  153. norot:
  154. rts
  155.  
  156. initother:
  157. lea    $60000,a0
  158. move.w    #$1600,d0
  159. clp:
  160. clr.l    (a0)+
  161. dbf    d0,clp
  162. rts
  163.  
  164. Wait:                    ; Wait.
  165. bsr    dostars
  166. bsr    dorotation
  167. btst    #6,$bfe001
  168. bne.s    wait
  169. rts
  170.  
  171. dostars:
  172. moveq    #0,d3
  173. moveq    #99,d2
  174. lea    $60000,a0            ; Bpl 1
  175. lea    $62c00,a1            ; Bpl 2
  176. lea    sine,a6                ; Sine table
  177. lea    posx,a5                ; X pos table
  178. lea    posy,a4                ; Y pos table
  179. lea    dire,a3                ; Direction table
  180.  
  181. thelot:
  182. moveq    #0,d0
  183. move.w    (a5),d0                ; Xpos * 100
  184. move.w    (a4),d1                ; Ypos * 100
  185. move.w    (a3)+,d7            ; Direction (angle * 2)
  186. move.w    d7,d6
  187. add.w    #180,d6                ; Y direction
  188. cmpi.w    #720,d6
  189. blt.s    notnow
  190. subi.w    #720,d6                ; cos(360)=cos(0)
  191. notnow:
  192.  
  193. movem.l    d0/d1/d3,-(a7)
  194. divu    #100,d0
  195. divu    #100,d1
  196. mulu    #44,d1
  197. move.w    d0,d3
  198. asr.w    #3,d3
  199. not.b    d0                ; DELETE OLD STAR
  200. andi.w    #7,d0
  201. add.l    d3,d1
  202. bclr    d0,0(a0,d1)
  203. bclr    d0,0(a1,d1)
  204. lea    $2c00(a1),a1
  205. bclr    d0,0(a1,d1)
  206. lea    -$2c00(a1),a1
  207. movem.l    (a7)+,d0/d1/d3
  208.  
  209. move.l    d7,-(a7)
  210. move.w    (a6,d7.w),d5            ; Get sine value
  211. move.w    (a6,d6.w),d4            ; Get cosine value
  212. move.w    198(a3),d7
  213. divu    #25,d7
  214. mulu    d7,d4
  215. mulu    d7,d5
  216. divu    #100,d4
  217. divu    #100,d5
  218. move.l    (a7)+,d7
  219.  
  220. add.w    d5,d0                ; Xpos
  221. add.w    d4,d1                ; Ypos
  222. move.w    d0,(a5)+            ; Xpos save
  223. move.w    d1,(a4)+            ; YPos save
  224. divu    #100,d0                ; Xpos = Xpos/100 = Xpos
  225. divu    #100,d1                ; Ypos = Ypos/100 = Ypos
  226. cmpi.w    #352,d0
  227. bge.s    res
  228. cmpi.w    #0,d0
  229. blt.s    res
  230. cmpi.w    #256,d1
  231. bge.s    res
  232. cmpi.w    #0,d1
  233. bge.s    nores
  234. res:
  235. move.w    #176,d0
  236. move.w    #17600,-2(a5)            ; Save the pos'n
  237. move.w    #127,d1
  238. move.w    #12700,-2(a4)
  239. clr.w    198(a3)                ; Clear nummoves
  240. nores:
  241. addq.w    #1,198(a3)
  242.                     ; SETDOT
  243. move.l    d7,-(a7)
  244. mulu    #44,d1
  245. move.w    d0,d3
  246. asr.w    #3,d3                ; Divide by 8
  247. add.l    d3,d1
  248. not.b    d0
  249. andi.w    #7,d0
  250.  
  251. move.w    198(a3),d7
  252. divu    #32,d7
  253. addq.b    #1,d7
  254. cmpi.b    #7,d7
  255. ble.s    nofix
  256. moveq    #7,d7
  257. nofix:
  258. asr.b    #1,d7
  259. bcc.s    nopl1
  260. bset    d0,0(a0,d1)            ; Set point
  261. nopl1:
  262. asr.b    #1,d7
  263. bcc.s    nopl2
  264. bset    d0,0(a1,d1)
  265. nopl2:
  266. asr.b    #1,d7
  267. bcc.s    nopl3
  268. lea    $2c00(a1),a1
  269. bset    d0,(a1,d1)
  270. lea    -$2c00(a1),a1
  271. nopl3:
  272.  
  273. move.l    (a7)+,d7
  274.  
  275. dbf    d2,thelot
  276. rts
  277.  
  278. posx:
  279. dc.w    17600,17600,27600,07600,17600,12600,19600,29600,07600,01600
  280. dc.w    17600
  281. dc.w    27600,17600,17600,17600,17600,17600,17600,17600,17600,17600
  282. dc.w    17600
  283. dc.w    17600,15600,17600,15400,24300,30600,17600,11700,17600,17600
  284. dc.w    17600
  285. dc.w    17600,07600,03600,14600,12100,12600,13600,19600,11600,10600
  286. dc.w    17600
  287. dc.w    27100,17600,17600,26600,24600,29100,17600,31600,17600,17600
  288. dc.w    11600
  289. dc.w    19600,17600,22600,17600,27600,17600,17600,17600,17600,17600
  290. dc.w    24600
  291. dc.w    09600,17600,22600,17600,27600,17600,17600,17600,17600,17600
  292. dc.w    24600
  293. dc.w    09600,27600,22600,17600,27600,17600,17600,17600,17600,17600
  294. dc.w    24600
  295. dc.w    19600,17600,22600,17600,27600,17600,17600,17600,17600,17600
  296. dc.w    24600
  297. dc.w    19600,17600,22600,17600,27600,17600,17600,17600,17600,17600
  298. dc.w    24600
  299.  
  300. posy:
  301. dc.w    12700,12700,12700,12700,12700,12700,12700,12700,12700,12700
  302. dc.w    12700
  303. dc.w    12700,12700,12700,12700,12700,12700,12700,12700,12700,12700
  304. dc.w    12700
  305. dc.w    12700,02700,13700,14700,15700,16700,17700,18700,19700,12700
  306. dc.w    12700
  307. dc.w    02700,10700,19700,12700,12700,12700,12700,12700,12700,12700
  308. dc.w    12700
  309. dc.w    22700,12700,12700,12700,12700,12700,12700,12700,12700,12700
  310. dc.w    14700
  311. dc.w    19700,12700,16700,12700,12700,12700,12700,12700,12700,12700
  312. dc.w    18700
  313. dc.w    10700,16700,12700,12700,12700,12700,12700,12700,12700,12700
  314. dc.w    12700
  315. dc.w    18700,12700,12700,12700,12700,12700,12700,12700,12700,12700
  316. dc.w    12700
  317. dc.w    16700,17700,12700,12700,12700,12700,12700,12700,12700,12700
  318. dc.w    12700
  319. dc.w    14700,22700,19700,21700,20700,12700,12700,12700,12700,12700
  320. dc.w    12700
  321.  
  322. dire:
  323. dc.w    000,090,180,270,360,450,540,630,044,134
  324. dc.w    006,096,186,276,366,456,546,636,050,140
  325. dc.w    012,102,192,282,372,462,552,642,056,146
  326. dc.w    018,108,198,288,378,468,558,648,062,152
  327. dc.w    024,114,204,294,384,474,564,654,068,156
  328. dc.w    030,120,210,300,390,480,570,660,074,162
  329. dc.w    124,114,204,306,396,474,564,654,068,156
  330. dc.w    130,120,210,312,402,480,570,660,074,162
  331. dc.w    124,114,204,318,408,474,564,654,068,156
  332. dc.w    130,120,210,324,414,180,470,260,474,262
  333. nummoves:
  334. blk.w    100,0
  335.  
  336. copl:
  337. dc.w $0100,$3200
  338. dc.w $00e0,$0006,$00e2,$0000
  339. dc.w $00e4,$0006,$00e6,$2c00
  340. dc.w $00e8,$0006,$00ea,$5800
  341. dc.w $0102,$0000,$0104,$0030,$008e,$2480
  342. dc.w $0090,$24e0,$0092,$0030,$0094,$00d8
  343. dc.w $010a,$0000,$0108,$0000,$0120,$0000
  344. dc.w $0122,$0000
  345. dc.w $0182,$0666,$0184,$0888,$0186,$0aaa,$0188,$0bbb
  346. dc.w $018a,$0ccc,$018c,$0ddd,$018e,$0eee
  347. dc.w $0124,$0000,$0126,$0000,$0128,$0000,$012a,$0000
  348. dc.w $012c,$0000,$012e,$0000,$0130,$0000,$0132,$0000
  349. dc.w $0134,$0000,$0136,$0000,$0138,$0000,$013a,$0000
  350. dc.w $013c,$0000,$013e,$0000
  351. dc.w $0180,$0000,$0186,$0bbb
  352. dc.w $ffff,$fffe
  353.  
  354. sine:
  355. dc.w  0, 2, 6, 10, 12, 16,20, 24, 26, 30, 34, 38
  356. dc.w  40, 44, 48, 50, 54, 58,60, 64, 68, 70, 74, 78
  357. dc.w  80, 84, 86, 90, 92, 96,100, 102, 104, 108, 110, 114
  358. dc.w  116, 120, 122, 124, 128, 130, 132, 136, 138, 140, 142, 146
  359. dc.w  148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170
  360. dc.w  172, 174, 176, 178, 178, 180, 182, 184, 184, 186, 186, 188
  361. dc.w  190, 190, 192, 192, 194, 194, 194, 196, 196, 196, 198, 198
  362. dc.w  198, 198, 198, 198, 198, 198, 200, 198, 198, 198, 198, 198
  363. dc.w  198, 198, 198, 196, 196, 196, 194, 194, 194, 192, 192, 190
  364. dc.w  190, 188, 186, 186, 184, 184, 182, 180, 178, 178, 176, 174
  365. dc.w  172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150
  366. dc.w  148, 146, 142, 140, 138, 136, 132, 130, 128, 124, 122, 120
  367. dc.w  116, 114, 110, 108, 104, 102, 98, 96, 92, 90, 86, 84
  368. dc.w  80, 78, 74, 70, 68, 64, 60, 58, 54, 50, 48, 44
  369. dc.w  40, 38, 34, 30, 26, 24, 20, 16, 12, 10, 6, 2
  370. dc.w -2,-4,-8,-12,-14,-18,-22,-26,-28,-32,-36,-40
  371. dc.w -42,-46,-50,-52,-56,-60,-62,-66,-70,-72,-76,-80
  372. dc.w -82,-86,-88,-92,-94,-98,-102,-104,-106,-110,-112,-116
  373. dc.w -118,-122,-124,-126,-130,-132,-134,-138,-140,-142,-144,-148
  374. dc.w -150,-152,-154,-156,-158,-160,-162,-164,-166,-168,-170,-172
  375. dc.w -174,-176,-178,-180,-180,-182,-184,-186,-186,-188,-188,-190
  376. dc.w -192,-192,-194,-194,-196,-196,-196,-198,-198,-198,-200,-200
  377. dc.w -200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200,-200
  378. dc.w -200,-200,-200,-198,-198,-198,-196,-196,-196,-194,-194,-192
  379. dc.w -192,-190,-188,-188,-186,-186,-184,-182,-180,-180,-178,-176
  380. dc.w -174,-172,-170,-168,-166,-164,-162,-160,-158,-156,-154,-152
  381. dc.w -150,-148,-144,-142,-140,-138,-134,-132,-130,-126,-124,-122
  382. dc.w -118,-116,-112,-110,-106,-104,-100,-98,-94,-92,-88,-86
  383. dc.w -82,-80,-76,-72,-70,-66,-62,-60,-56,-52,-50,-46
  384. dc.w -42,-40,-36,-32,-28,-26,-22,-18,-14,-12,-8,-4
  385. end:
  386.